<?php
/**
 * Created by PhpStorm.
 * User: Edward
 * Date: 2019/5/31
 * Time: 15:10
 */

namespace app\admin\model;


class ShopCategory  extends  Base {

    /**
     * 获取商家主营类目
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function shopCategory(){
        return self::field('id,category')->select();
    }

    /**
     * 查询是否存在类目
     * @param $category
     * @return array|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function findCategoryByName($category){
        return self::field('category')->
        where(['category'=>$category])->find();
    }
    public static function createCategory($category){
        return self::create([
            'category' => $category
        ]);
    }
}